<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib prefix="sys" uri="/WEB-INF/tld/sys.tld" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>资管账单列表</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">

<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">支付表号</div>
                    <div class="field">
                        <input name="paySchNo" id="paySchNo" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">承租人名称</div>
                    <div class="field">
                        <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox col_33" id="searchInsCodeId" <sys:resourceAuth resCd="noThdOrg">style="display: none" </sys:resourceAuth>>
                    <div class="label">第三方机构</div>
                    <div class="field">
                        <select name="foundInsCode"  id="foundInsCode" >
                            <option value="" selected="selected">请选择</option>
                            <c:forEach items="${friBaseList}" var="fri">
                                <option value="${fri.insCode}">${fri.fundRasInsNmShow}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">应收时间</div>
                    <div class="field">
                        <input ligerui="width: 92" name="receivableTtlStartDate" id="receivableTtlStartDate" type="text" class="ui-datepicker" value="">
                        -
                        <input ligerui="width: 92" name="receivableTtlEndeDate" id="receivableTtlEndeDate" type="text" class="ui-datepicker" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">实收时间</div>
                    <div class="field">
                        <input ligerui="width: 92" name="receivedTtlStartDate" id="receivedTtlStartDate" type="text" class="ui-datepicker" value="">
                        -
                        <input ligerui="width: 92" name="receivedTtlEndDate" id="receivedTtlEndDate" type="text" class="ui-datepicker" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <span class="c_red">实收罚息为账单累计实收罚息，不受查询条件影响</span>
                </div>
                <div class="clearFix"></div>
                <div class="formBtns notRight">
                    <span id="searchBtn" class="sq-button sq-button-round"></i>查询</span>
                    <span id="clearBtn" class="sq-button sq-button-round"></i>清空</span>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                </div>

            </div>
        </form>
    </div>

    <div class="sqPanel" style="margin-bottom: 0;">
        <div class="sqPanel_head">
            <table class="table_full">
                <tr>
                    <td><b>应收租金合计(元): </b><span id="arAmt"/></td>
                    <td><b>实收租金合计(元): </b><span id="realyAmt"/></td>
                    <td><b>实收罚息合计(元): </b><span id="penaltyAmt"/></td>
                </tr>
            </table>
        </div>
        <div class="sqPanel_body">
            <div id="ligergrid1" class="sq-grid"></div>
        </div>
    </div>
</div>

<script type="text/javascript">
    var grid = null,form=null;
    $(function () {
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/capital/capRepayment/initList.do',
            method: 'get',
            columns: [
                {display: '支付表号', name: 'paySchNo', width: 200, align: 'left', enabledSort: false},
                {display: '承租人名称', name: 'cstNm', width: 100, align: 'left', enabledSort: false},
                {display: '起租日', name: 'beginRentTime', width: 150, align: 'left', enabledSort: false,render:renderDate},
                {display: '金融机构名称', name: 'foundInsName', width: 120, align: 'left', enabledSort: true},
                {
                    display: '应收租金(元)', name: 'receivableTtlAmt', width: 120, align: 'left', enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '&yen;' + FormatMoney(rowdata.receivableTtlAmt / 100);
                    }
                },
                {
                    display: '实收租金(元)', name: 'receivedTtlAmt', width: 120, align: 'left', enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '&yen;' + FormatMoney(rowdata.receivedTtlAmt / 100);
                    }
                },
                {
                    display: '实收罚息(元)', name: 'receivedIntereAmt', width: 100, align: 'left', enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '&yen;' + FormatMoney(rowdata.receivedIntereAmt / 100);
                    }
                },
                {
                    display: '操作', width: 100, align: 'left', enabledSort: false,
                    render: function (rowdata, index, value) {
                        return '<a href="javascript:;" onclick="repaymentDtl('+rowdata.paySchId+')">还款情况</a>';
                    }
                },
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: true,
            enabledEdit: true,
        });
    });
    form = $("#searchBar").ligerForm();
    getAmtSummary();
    /* 查询 */
    $("#searchBtn").click(function (event) {
        form = liger.get("searchBar");
        var data = form.getData();
        for (name in data) {
            grid.setParm(name, data[name]);
        }
        grid.reload();
        getAmtSummary();
    });
    /* 清空 */
    $("#clearBtn").click(function (event) {
        clearLigerForm("searchBar");
    });
    callback = function () {
        grid.reload();
    };
    //查看支付表详情
    function repaymentDtl(paySchId){
        // Add_navTab( 'tab_prj_pay_detail'+paySchId,'查看支付表详情','<%=path%>/capital/capRepayment/toPrjPrdPayDetailPage.do?paySchId='+paySchId);
        var payDetailUrl = '<%=path%>/project/prjprdpayschm/toPrjPrdPaySchMDetailPage.do?id='+paySchId;
        Add_navTab('tab_prj_quat_prps_pay'+paySchId,'查看还款情况',payDetailUrl);
    }

    //查询汇总
    function getAmtSummary() {
        var data = form.getData();
        $.ajax({
            type: 'get',
            dataType: 'json',
            data: data,
            url: '<%=path%>/capital/capRepayment/getSumAmt.do',
            success: function (msg) {
                if(msg.penaltySum){
                    $("#penaltyAmt").text(FormatMoney(msg.penaltySum / 100));
                }else{
                    $("#penaltyAmt").text("¥0.00");
                }
                if(msg.receivableTtlAmtSum){
                    $("#arAmt").text(FormatMoney(msg.receivableTtlAmtSum / 100));
                }else{
                    $("#arAmt").text("¥0.00");
                }
                if(msg.receivedTtlAmtSum){
                    $("#realyAmt").text(FormatMoney(msg.receivedTtlAmtSum / 100));
                }else{
                    $("#realyAmt").text("¥0.00");
                }
            }
        });
    }
    //格式化金额
    function moneyChange(value) {
        var h = '';
        if(value&&value!="null"){
            h+=fmoney(value, 2);
        }else{
            h+="0.00";
        }
        return h;
    }
    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }
</script>

</body>
</html>
